package org.iron.services;

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.xml.rpc.ServiceException;

import org.tempuri.Device;
import org.tempuri.UniOPMServiceSoap;
import org.tempuri.UniOPMServiceSoapProxy;

public class PrinterServiceImpl implements PrinterService
{

    @Override
    public List<Device> getDeviceList()
    {
        UniOPMServiceSoap soap = new UniOPMServiceSoapProxy();

        Device[] list = null;
        try
        {
            list = soap.getDevices2("");
        }
        catch (RemoteException e1)
        {
            e1.printStackTrace();
        }

        return Arrays.asList(list);
    }

    @Override
    public List<Device> getDeviceList(String campus)
    {
        UniOPMServiceSoap soap = new UniOPMServiceSoapProxy();

        Device[] list = null;

        List<Device> ls = new ArrayList<Device>();
        try
        {
            list = soap.getDevices2("");

            for (Device i : list)
            {
                if (!i.getName().startsWith("南校区"))
                {
                    ls.add(i);
                }
            }
        }
        catch (RemoteException e1)
        {
            e1.printStackTrace();
        }
        return ls;

    }
}
